package yuxi;

//添加学生到集合中并且遍历输出

import java.util.ArrayList;

public class ArrayListTest02 {
    public static void main(String[] args) {
        ArrayList<student> array = new ArrayList<student>();

        student s1 = new student("赵丽颖",30);
        student s2 = new student("杨幂",35);
        student s3 = new student ("迪丽热巴",33);

        array.add(s1);
        array.add(s2);
        array.add(s3);

        for (int i = 0; i < array.size(); i++) {
            student s = array.get(i);
            System.out.println(s.getName()+","+s.getAge());
        }
    }

}
